﻿

namespace Jhong.FunMVC
{
    using Microsoft.Owin.Helpers;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    class DefaultPostCollection
    {
        public static void Fill(Request request)
        {
            var buffer = new byte[request.ContentLength];
            var contentLength = request.ContentLength;
            var offset = 0;
            while (contentLength > 0)
            {
                var readLength = request.BodyStream.Read(buffer, offset, contentLength);
                if (readLength <= 0) break;
                offset += readLength;
                contentLength -= readLength;
            }
            var txt = Encoding.UTF8.GetString(buffer);
            request.Forms.FormCollection = WebHelpers.ParseForm(txt);
        }



    }
}
